package com.twu.biblioteca.models;

/**
 * Created with IntelliJ IDEA.
 * User: ema93sh
 * Date: 8/16/13
 * Time: 4:55 PM
 */
public class Movie {

    private String director;
    private Integer year;
    private String name;
    private float rating;
    private boolean rated;

    public Movie(String name) {
        setName(name);
    }

    @Override
    public boolean equals(Object otherObject)
    {
        if (otherObject == this)
        {
            return true;
        }

        if (!(otherObject instanceof Movie))
        {
            return false;
        }

        Movie movie = (Movie) otherObject;

        return movie.getName().equalsIgnoreCase(this.getName()) && movie.getDirector().equalsIgnoreCase(this.getDirector())
                && movie.getYear().equals(this.getYear());
    }

    public String getDirector() {
        return director;
    }

    public void setDirector(String director) {
        this.director = director;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getRating() {
        if (isRated()) {
            return this.rating;
        }
        return -1;
    }

    public void setRating(float rating) {
          if (rating > 0 && rating <= 10)
          {
              this.rating = rating;
              this.rated = true;
          }
    }

    public boolean isRated() {
        return rated;
    }
}
